<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>推送列表页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
    <meta name="author" content="Muhammad Usman">

    <!-- The styles -->
    <link id="bs-css" href="/posterwebchat/Public/charisma-master/css/bootstrap-cerulean.min.css" rel="stylesheet">

    <link href="/posterwebchat/Public/charisma-master/css/charisma-app.css" rel="stylesheet">
    <link href='/posterwebchat/Public/charisma-master/bower_components/fullcalendar/dist/fullcalendar.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/bower_components/fullcalendar/dist/fullcalendar.print.css' rel='stylesheet' media='print'>
    <link href='/posterwebchat/Public/charisma-master/bower_components/chosen/chosen.min.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/bower_components/colorbox/example3/colorbox.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/bower_components/responsive-tables/responsive-tables.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/bower_components/bootstrap-tour/build/css/bootstrap-tour.min.css' rel='stylesheet'>

    <link href='/posterwebchat/Public/charisma-master/css/jquery.noty.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/css/noty_theme_default.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/css/elfinder.min.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/css/elfinder.theme.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/css/jquery.iphone.toggle.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/css/uploadify.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/charisma-master/css/animate.min.css' rel='stylesheet'>
    <link href='/posterwebchat/Public/css/common.css' rel='stylesheet'>

    <!-- jQuery -->
    <script src="/posterwebchat/Public/charisma-master/bower_components/jquery/jquery.min.js"></script>

    <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- The fav icon -->
    <link rel="shortcut icon" href="img/favicon.ico">
</head>
<body>
<!-- topbar starts -->
<div class="navbar navbar-default" role="navigation">

    <div class="navbar-inner">
        <button type="button" class="navbar-toggle pull-left animated flip">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="index.html"> <img alt="Charisma Logo" src="/sae/Public/charisma-master/img/logo20.png" class="hidden-xs"/>
            <span>Charisma</span></a>

        <!-- user dropdown starts -->
        <div class="btn-group pull-right">
            <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                <i class="glyphicon glyphicon-user"></i><span class="hidden-sm hidden-xs"><?php echo (session('userName')); ?></span>
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <li><a href="#">Profile</a></li>
                <li class="divider"></li>
                <li><a href="<?php echo U('logout');?>">Logout</a></li>
            </ul>
        </div>
        <!-- user dropdown ends -->

        <!-- theme selector starts -->
        <div class="btn-group pull-right theme-container animated tada">
            <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                <i class="glyphicon glyphicon-tint"></i><span
                    class="hidden-sm hidden-xs"> Change Theme / Skin</span>
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu" id="themes">
                <li><a data-value="classic" href="#"><i class="whitespace"></i> Classic</a></li>
                <li><a data-value="cerulean" href="#"><i class="whitespace"></i> Cerulean</a></li>
                <li><a data-value="cyborg" href="#"><i class="whitespace"></i> Cyborg</a></li>
                <li><a data-value="simplex" href="#"><i class="whitespace"></i> Simplex</a></li>
                <li><a data-value="darkly" href="#"><i class="whitespace"></i> Darkly</a></li>
                <li><a data-value="lumen" href="#"><i class="whitespace"></i> Lumen</a></li>
                <li><a data-value="slate" href="#"><i class="whitespace"></i> Slate</a></li>
                <li><a data-value="spacelab" href="#"><i class="whitespace"></i> Spacelab</a></li>
                <li><a data-value="united" href="#"><i class="whitespace"></i> United</a></li>
            </ul>
        </div>
        <!-- theme selector ends -->

        <ul class="collapse navbar-collapse nav navbar-nav top-menu">
            <li><a href="#"><i class="glyphicon glyphicon-globe"></i> Visit Site</a></li>
            <li class="dropdown">
                <a href="#" data-toggle="dropdown"><i class="glyphicon glyphicon-star"></i> Dropdown <span
                        class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="#">Action</a></li>
                    <li><a href="#">Another action</a></li>
                    <li><a href="#">Something else here</a></li>
                    <li class="divider"></li>
                    <li><a href="#">Separated link</a></li>
                    <li class="divider"></li>
                    <li><a href="#">One more separated link</a></li>
                </ul>
            </li>
            <li>
                <form class="navbar-search pull-left">
                    <input placeholder="Search" class="search-query form-control col-md-10" name="query"
                           type="text">
                </form>
            </li>
        </ul>
    </div>
</div>
<!-- topbar ends -->
<div class="ch-container">
    <div class="row">
        <!-- left menu starts -->
        <div class="col-sm-2 col-lg-2">
            <div class="sidebar-nav">
                <div class="nav-canvas">
                    <div class="nav-sm nav nav-stacked">

                    </div>
                    <ul class="nav nav-pills nav-stacked main-menu">
                        <li class="nav-header">功能</li>
                        <li><a class="ajax-link" href="<?php echo U('poster');?>"><i
                                class="glyphicon glyphicon-home"></i><span> 主页</span></a>
                        </li>
                        <li><a class="ajax-link" href="<?php echo U('posterList');?>"><i
                                    class="glyphicon glyphicon-align-justify"></i><span> 推送列表</span></a>
                        </li>
                        <li><a class="" href="<?php echo U('newPoster');?>"> <i
                                class="glyphicon glyphicon-plus-sign"></i><span> 新增推送</span></a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <!--/span-->
        <!-- left menu ends -->

        <noscript>
            <div class="alert alert-block col-md-12">
                <h4 class="alert-heading">Warning!</h4>

                <p>You need to have <a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>
                    enabled to use this site.</p>
            </div>
        </noscript>

        <div id="content" class="col-lg-10 col-sm-10">
            <!-- content starts -->
                <div>
        <ul class="breadcrumb">
            <li>
                <a href="#">Home</a>
            </li>
            <li>
                <a href="#">Tables</a>
            </li>
        </ul>
    </div>

    <div class="row">
    <div class="box col-md-12">
    <div class="box-inner">
    <div class="box-header well" data-original-title="">
        <h2><i class="glyphicon glyphicon-user"></i>推送列表</h2>
    </div>
    <div class="box-content">
        <a class="btn btn-danger" id="deleteAll" href="#"><i class="glyphicon glyphicon-trash"></i> 批量删除</a>
        <br/>
        <br/>
        <table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
    <thead>
    <tr>
        <th><input type="checkbox" id="selectAll" name="selectAll"></th>
        <th>标题</th>
        <th>创建时间</th>
        <th>创建人</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <?php if(is_array($data)): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
            <td><input type="checkbox" value="<?php echo ($vo["post_id"]); ?>" name="post_id"></td>
            <input type="hidden">
            <td><?php echo ($vo["post_title"]); ?></td>
            <td class="center"><?php echo ($vo["create_time"]); ?></td>
            <td class="center"><?php echo ($vo["create_by"]); ?></td>
            <td class="center">
                <?php if($vo["status"] == 1): ?><span class="label-success label label-default">已启用</span>
                    <?php else: ?>
                    <span class="label-default label label-danger">已禁用</span><?php endif; ?>
            </td>
            <td class="center">
                <a class="btn btn-success" href="<?php echo U('Index/posterPreview',array('post_id'=>$vo['post_id']));?>">
                    <i class="glyphicon glyphicon-zoom-in icon-white"></i>
                    预览
                </a>
                <a class="btn btn-info" href="<?php echo U('posterEdit',array('post_id'=>$vo['post_id']));?>">
                    <i class="glyphicon glyphicon-edit icon-white"></i>
                    编辑
                </a>
                <a class="btn btn-danger deleteOne" href="javascript:void(0);" ajax-href="<?php echo U('posterDelete');?>">
                    <i class="glyphicon glyphicon-trash icon-white"></i>
                    删除
                </a>
            </td>
        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
    </tbody>
    </table>
        <!--提示信息-->
    <button class="btn btn-primary noty" id="noty_success" style="display: none;"
            data-noty-options="{&quot;text&quot;:&quot;删除成功&quot;,&quot;layout&quot;:&quot;top&quot;,&quot;type&quot;:&quot;success&quot;,&quot;closeButton&quot;:&quot;true&quot;}">
        <i class="glyphicon glyphicon-bell icon-white"></i> Bottom Full Width with Close Button
    </button>
    <button class="btn btn-primary noty" id="noty_error" style="display: none;"
            data-noty-options="{&quot;text&quot;:&quot;删除失败！&quot;,&quot;layout&quot;:&quot;top&quot;,&quot;type&quot;:&quot;error&quot;,&quot;animateOpen&quot;: {&quot;opacity&quot;: &quot;show&quot;}}">
        <i class="glyphicon glyphicon-bell icon-white"></i> Center (fade)
    </button>
    <!--提示信息完-->
    </div>
    </div>
    </div>
    <!--/span-->
    </div><!--/row-->
    <!-- content ends -->
    </div><!--/#content.col-md-0-->
</div><!--/fluid-row-->

<footer class="row">
    <p class="col-md-9 col-sm-9 col-xs-12 copyright">&copy; <a href="http://usman.it" target="_blank">Muhammad
        Usman</a> 2012 - 2015</p>

    <p class="col-md-3 col-sm-3 col-xs-12 powered-by">Powered by: <a
            href="http://usman.it/free-responsive-admin-template">Charisma</a></p>
</footer>

</div><!--/.fluid-container-->

<!-- external javascript -->

<script src="/posterwebchat/Public/charisma-master/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

<!-- library for cookie management -->
<script src="/posterwebchat/Public/charisma-master/js/jquery.cookie.js"></script>
<!-- calender plugin -->
<script src='/posterwebchat/Public/charisma-master/bower_components/moment/min/moment.min.js'></script>
<script src='/posterwebchat/Public/charisma-master/bower_components/fullcalendar/dist/fullcalendar.min.js'></script>
<!-- data table plugin -->
<script src='/posterwebchat/Public/charisma-master/js/jquery.dataTables.min.js'></script>

<!-- select or dropdown enhancer -->
<script src="/posterwebchat/Public/charisma-master/bower_components/chosen/chosen.jquery.min.js"></script>
<!-- plugin for gallery image view -->
<script src="/posterwebchat/Public/charisma-master/bower_components/colorbox/jquery.colorbox-min.js"></script>
<!-- notification plugin -->
<script src="/posterwebchat/Public/charisma-master/js/jquery.noty.js"></script>
<!-- library for making tables responsive -->
<script src="/posterwebchat/Public/charisma-master/bower_components/responsive-tables/responsive-tables.js"></script>
<!-- tour plugin -->
<script src="/posterwebchat/Public/charisma-master/bower_components/bootstrap-tour/build/js/bootstrap-tour.min.js"></script>
<!-- star rating plugin -->
<script src="/posterwebchat/Public/charisma-master/js/jquery.raty.min.js"></script>
<!-- for iOS style toggle switch -->
<script src="/posterwebchat/Public/charisma-master/js/jquery.iphone.toggle.js"></script>
<!-- autogrowing textarea plugin -->
<script src="/posterwebchat/Public/charisma-master/js/jquery.autogrow-textarea.js"></script>
<!-- multiple file upload plugin -->
<script src="/posterwebchat/Public/charisma-master/js/jquery.uploadify-3.1.min.js"></script>
<!-- history.js for cross-browser state change on ajax -->
<script src="/posterwebchat/Public/charisma-master/js/jquery.history.js"></script>
<!-- application script for Charisma demo -->
<script src="/posterwebchat/Public/charisma-master/js/charisma.js"></script>
<script src="/posterwebchat/Public/charisma-master/js/jquery.IvanDialog.js"></script>
</body>
</html>

    <script>
        $("#selectAll").on('change',function(){
            $(this).parents("table").find("tbody input[name=post_id]").prop("checked", $(this).prop("checked"));
        });
        $("#deleteAll").on("click",function(){
            var idStr='';
            var _this= $(this);
            $(".table").find("input[name=post_id]").each(function(){
                idStr+=$(this).val()+',';
            });
            idStr = idStr.substring(0,idStr.length-1);
            $.ajax({ url:"<?php echo U('posterDelete');?>" , data: {idStr:idStr}, type: "post", dataType: "json", cache: false, async: true,
                success: function(data){
                    if(!!data && data.status){
                        $("#noty_success").click();
                        _this.parents("tr").remove();
                    }else{
                        $("#noty_error").click();
                    }
                },
                error: function (XMLresponseText){
                    alert(XMLresponseText);
                }
            });
        })
        $(".deleteOne").on("click",function(){
            var _this= $(this);
            $.ajax({ url:$(this).attr("ajax-href"),data:{idStr:$(this).parents('tr').find("input[name=post_id]").val()}, type: "post", dataType: "json", cache: false, async: true,
                success: function(data){
                    if(!!data && data.status){
                        $.IvanDialogOpen({
                            Type: 'tips',
                            Info: "删除数据成功",
                            Plugins: { CloseTime: 1200,CloseFun:true},
                            FunOk: function () {
                               window.location.reload(true);
                            }
                        });
                    }else{
                        $.IvanDialogOpen({
                            Type: 'tips',
                            Info: "删除失败",
                            Plugins: { CloseTime: 1200 }
                        });
                    }
                },
                error: function (XMLresponseText){
                    alert(XMLresponseText);
                }
            });
        })
    </script>